package com.lxk.util.wxpay;

import com.github.wxpay.sdk.WXPayConfig;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * 小程序 - 微信支付相关配置
 * @author JohnSoybean
 *
 */
public class MiniWxPayConfig implements WXPayConfig{

	/**
	 * CFG 服务器证书放置位置
	 */
	private static String certPath = "/usr/local/tomcat/api/cert/wxpay/apiclient_cert.p12";

	/**
	 * CFG 配置信息
	 */
	private static String appId = "wxfacb13f8a3a00fe5";
	private static String mchId = "1601213289";
	private static String key = "8f064ce01a5442e8a00fed9f69a5a975";

    private byte[] certData;

    public MiniWxPayConfig() throws Exception {
        File file = new File(certPath);
        InputStream certStream = new FileInputStream(file);
        this.certData = new byte[(int) file.length()];
        certStream.read(this.certData);
        certStream.close();
    }

    public String getAppID() {
    	return appId;
    }

    public String getMchID() {
        return mchId;
    }

    public String getKey() {
        return key;
    }

    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
        return certBis;
    }

    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    public int getHttpReadTimeoutMs() {
        return 10000;
    }
}
